﻿module Preprocessor.History

open Cabs
open Clexer
open Lexer
open PrintUtils
open Prep
open System.IO
open System.Text

let addHistory (prep:Prep) originalText newText loc changed= 
    let add () = 
        match (originalText, newText) with
            | ("", _) -> prep.History <- Insert( newText, loc)::prep.History
            | (_ , "") -> prep.History <- Delete (originalText, loc)::prep.History
            | _ -> prep.History <- Changed(originalText, newText, loc)::prep.History   
    if ((loc.filename = prep.SourceFile && changed) || (loc.filename <> prep.SourceFile && (not changed))) then
        add ()